#!/bin/bash

export NAME=mysql

# 限制内存4G，CPU 0，1，2核
docker run -d \
        -p 13306:3306 \
        --user 501:20 \
        -e MYSQL_ROOT_PASSWORD=123456 \
        -v `pwd`/conf/:/etc/mysql/:rw \
        -v `pwd`/data/:/var/lib/mysql/:rw \
        -v /etc/localtime:/etc/localtime:ro \
        -m 4g --cpuset-cpus=0,1,2 \
        --name mysql chad/mysql


# 生成ssl 并重启容器
test -f ./conf/certs/ca.pem || \
(docker exec $NAME /etc/mysql/mkrsa.sh && docker restart $NAME)


#docker run -ti -v mysql-data:/var/lib/mysql:rw -e MYSQL_USER=chad -e MYSQL_PASSWORD=123123 -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 --name mysql chad/mysql
